package team.seekers.hula.island.island.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.seekers.hula.common.entity.PageResult;
import team.seekers.hula.island.island.entity.dto.IslandPageQueryDTO;
import team.seekers.hula.island.island.entity.vo.IslandManageInfoVO;
import team.seekers.hula.island.island.entity.vo.IslandPageListVO;
import team.seekers.hula.auth.service.MindUtils;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.island.island.entity.dto.IslandListDTO;
import team.seekers.hula.island.island.entity.dto.IslandUpdateDTO;
import team.seekers.hula.island.island.entity.vo.IslandListVO;
import team.seekers.hula.island.island.entity.dto.IslandAddDTO;
import team.seekers.hula.island.island.service.IslandService;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author ekin
 * @Description GOOD
 * @mood happy
 */
@Controller
@ApiResponseBody
@RequestMapping("/manage/island")
public class IslandManageController {

    @Resource
    private IslandService islandService;

    /**
     *
     * 共创页创建浪屿
     */
    @PostMapping("/add")
    public void add(@RequestBody IslandAddDTO addVO){
        addVO.setUserId(MindUtils.getUserId());
        islandService.add(addVO);
    }

    @GetMapping("/info")
    public IslandManageInfoVO query(String islandId) {
        return islandService.queryManageInfoById(islandId);
    }


    /**
     *
     * 共创页浪屿列表
     */
    @GetMapping("/admin")
    public List<IslandListVO> listAdmin() {
        IslandListDTO islandListDTO = new IslandListDTO();
        islandListDTO.setUserId(MindUtils.getUserId());
        return islandService.listAdmin(islandListDTO);
    }

    @PostMapping("/update")
    public void update(@RequestBody @Valid IslandUpdateDTO reqDTO) {
        islandService.updateIsland(reqDTO);
    }

//    @GetMapping("/page")
//    public PageResult<IslandManageInfoVO> pageList(CheckPageQueryDTO queryDTO){
//        return auditService.getCheckList(queryDTO);
//    }

    // page
    @GetMapping("/page")
    public PageResult<IslandPageListVO> list(IslandPageQueryDTO islandQuery) {
        return islandService.pageManageList(islandQuery);
    }

}
